from exts import db


class User(db.Model):
    __tablename__ = "user"  # 表名
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)  # 创建属性,类型为integer,设为主键,自增
    username = db.Column(db.String(100), nullable=False)  # valchar(100), 非空
    password = db.Column(db.String(100), nullable=False)  # valchar(100), 非空

    def to_dict(self):
        user_dict = {
            "id": self.id,
            "username": self.username,
            "password": self.password
        }
        return user_dict
